package com.niit.mall.api.fallback;


import com.niit.mall.api.client.CartClient;
import com.niit.mall.common.api.CommonResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

/**
 * @BelongsProject: pardo_mall_backend
 * @BelongsPackage: com.niit.mall.api.fallback
 * @Author: ChuXuan
 * @CreateTime: 2025-06-08  03:12
 * @Description: 购物车服务降级处理
 * @Version: 1.0
 */
@Slf4j
public class CartClientFallbackFactory implements FallbackFactory<CartClient> {
	@Override
	public CartClient create(Throwable throwable) {
		return new CartClient() {
			@Override
			public CommonResult<Void> reduceStock(Map<Long, Integer> productIdToQuantityMap) {
				log.error("调用购物车服务失败，降级处理", throwable);
				return CommonResult.failed("购物车服务降级处理");
			}

		};
	}
}
